package com.gome.ocean.controller.gddl.app;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gome.ocean.common.utils.ResponsePage;
import com.gome.ocean.dao.model.gddl.AppDatasourceBO;
import com.gome.ocean.service.base.BaseController;
import com.gome.ocean.service.gddl.AppDatasourceService;


/**
 * Created by liuqingxia on 2016/3/23.
 */
@Controller
@RequestMapping("/tddl/appDataSource")
public class AppDataSourceController extends BaseController {

    private static final Logger  LOG = LoggerFactory.getLogger(AppDataSourceController.class);
    @Autowired
    private AppDatasourceService appDatasourceService;

    @RequestMapping(value = "/findById", method = RequestMethod.POST)
    @ResponseBody
    private ResponsePage findAppDataSourceByDataSourceId(@RequestParam("id") long id) {
        ResponsePage page = getResponsePage();
        try {
            AppDatasourceBO appDatasource = appDatasourceService.findAppDatasourceBOById(id);
            if (null == appDatasource) {
                return page.emptyPage("未查询到结果");
            }
            return page.setSingleObject(appDatasource, "查询成功");
        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
            return page.setErrorMsg(e.getMessage());
        }
    }

}
